{include file="public/common" /}

<fieldset class="layui-elem-field layui-field-title" style="text-align:center">
    <legend> 社区</legend>
</fieldset>


<form class="layui-form" action="" style="padding:5px" id="seller_goods_form">

    <!---主键id--->
    <input type="hidden" name="id" value="<?php echo isset($data->id)?$data->id:0?>">
    <div class="layui-form-item">
        <label class="layui-form-label">区域</label>

        <div class="layui-input-inline">
            <select lay-filter="city1" name="province_id">
                <option value="">请选择省</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select lay-filter="city2" name="city_id">
                <option value="">请选择市</option>
            </select>
        </div>
        <div class="layui-input-inline">
            <select lay-filter="city" name="county_id">
                <option value="">请选择县/区</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>

        <div class="layui-input-block">
            <input type="text" name="community_name" autocomplete="off" lay-verify="required" placeholder="名称"
                   class="layui-input" value="<?php echo isset($data->community_name)?$data->community_name:''?>">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>

        <div class="layui-input-block">
            <input type="text" name="community_address" autocomplete="off" placeholder="地址"
                   class="layui-input" value="<?php echo isset($data->community_address)?$data->community_address:''?>">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn"  name="submit" value="1">立即提交</button>
        </div>
    </div>
</form>


<script>


    layui.use(['form', 'element'], function () {
        var form = layui.form()
                , layer = layui.layer
                , layedit = layui.layedit;
        /**
         * 一级城市
         */
        $.post("/index/tool/city", {"pid": 0}, function (data) {
            if (data.code = 0) {
                return false;
            }
            var html = "";
            $.each(data.data, function (k, v) {
                html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
            });
            $("select[lay-filter='city1']").html(html);
            form.render('select');

        });
        /**
         * 二级城市
         */
        form.on('select(city1)', function (data) {
            var val = data.value;
            $.post("/index/tool/city", {"pid": val}, function (data) {
                if (data.code = 0) {
                    return false;
                }
                var html = "";
                html += "<option value=''>下拉选择</option>";
                $.each(data.data, function (k, v) {
                    html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
                });
                $("select[lay-filter='city2']").html(html);
                form.render('select');
            });

        });
        /**
         * 三级城市
         */
        form.on('select(city2)', function (data) {
            var val = data.value;
            $.post("/index/tool/city", {"pid": val}, function (data) {
                if (data.code = 0) {
                    return false;
                }
                var html = "";
                html += "<option value=''>下拉选择</option>";
                $.each(data.data, function (k, v) {
                    html += "<option value='" + v.city_id + "'>" + v.city_name + "</option>";
                });
                $("select[lay-filter='city']").html(html);
                form.render('select');
            });
        });

    });

</script>